package com.sky.mapper;

import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.entity.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    List<Dish> findAll(DishPageQueryDTO pageQueryDTO);

    @Select("select count(*) from dish")
    long count();

    @Update("update dish set status = #{status} where id = #{id}")
    void status(Integer status, int id);

    @Delete("delete from dish where id = #{id}")
    void delete(Integer id);

    @Select("select * from dish where id = #{id}")
    Dish findById(Integer id);

    List<Setmeal> queryDish(DishPageQueryDTO queryDTO);


    @Update("update setmeal set status = #{status} where id = #{id}")
    void updatastatus(Integer status, int id);


    @Delete("delete from setmeal where id = #{id}")
    void deletes(Integer id);


    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> list(Dish dish);


    @Select("select * from dish_flavor where dish_id = #{id}")
    List<DishFlavor> getByDishId(Long id);
}
